package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProDaily;
import com.ruoyi.system.service.IProDailyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日日报汇总Controller
 * 
 * @author ruoyi
 * @date 2024-10-08
 */
@RestController
@RequestMapping("/system/daily")
public class ProDailyController extends BaseController
{
    @Autowired
    private IProDailyService proDailyService;

    /**
     * 查询每日日报汇总列表
     */
    @PreAuthorize("@ss.hasPermi('system:daily:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProDaily proDaily)
    {
        startPage();
        List<ProDaily> list = proDailyService.selectProDailyList(proDaily);
        return getDataTable(list);
    }

    /**
     * 导出每日日报汇总列表
     */
    @PreAuthorize("@ss.hasPermi('system:daily:export')")
    @Log(title = "每日日报汇总", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProDaily proDaily)
    {
        List<ProDaily> list = proDailyService.selectProDailyList(proDaily);
        ExcelUtil<ProDaily> util = new ExcelUtil<ProDaily>(ProDaily.class);
        util.exportExcel(response, list, "每日日报汇总数据");
    }

    /**
     * 获取每日日报汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:daily:query')")
    @GetMapping(value = "/{dailyId}")
    public AjaxResult getInfo(@PathVariable("dailyId") Long dailyId)
    {
        return success(proDailyService.selectProDailyByDailyId(dailyId));
    }

    /**
     * 新增每日日报汇总
     */
    @PreAuthorize("@ss.hasPermi('system:daily:add')")
    @Log(title = "每日日报汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProDaily proDaily)
    {
        return toAjax(proDailyService.insertProDaily(proDaily));
    }

    /**
     * 修改每日日报汇总
     */
    @PreAuthorize("@ss.hasPermi('system:daily:edit')")
    @Log(title = "每日日报汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProDaily proDaily)
    {
        return toAjax(proDailyService.updateProDaily(proDaily));
    }

    /**
     * 删除每日日报汇总
     */
    @PreAuthorize("@ss.hasPermi('system:daily:remove')")
    @Log(title = "每日日报汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dailyIds}")
    public AjaxResult remove(@PathVariable Long[] dailyIds)
    {
        return toAjax(proDailyService.deleteProDailyByDailyIds(dailyIds));
    }
}
